package com.yuexun.dhdoctor.module.contractmanage.ui;

import android.widget.TextView;


import com.yuexun.dhdoctor.R;
import com.yuexun.dhdoctor.base.BaseEntity;
import com.yuexun.dhdoctor.base.BaseKJActivity;
import com.yuexun.dhdoctor.config.AppConfig;
import com.yuexun.dhdoctor.module.contractmanage.bean.ContractManageInspectDetailBean;
import com.yuexun.dhdoctor.module.contractmanage.model.impl.ContractManageModel;
import com.yuexun.dhdoctor.module.contractmanage.presenter.IContractManageInspectDetailPresenter;
import com.yuexun.dhdoctor.module.contractmanage.presenter.impl.ContractManageInspectDetailPresenter;
import com.yuexun.dhdoctor.module.contractmanage.ui.view.IContractManageInspectDetailView;

import org.kymjs.kjframe.utils.PreferenceHelper;

import java.util.HashMap;
import java.util.Map;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;

/**
 * Created by work-jx on 2016/10/27.
 */
public class Act_ContractManageInspectDetail extends BaseKJActivity implements IContractManageInspectDetailView {
    @Bind(R.id.title_tv)
    TextView titleTv;
    @Bind(R.id.inspectdetail_name)
    TextView inspectdetailName;
    @Bind(R.id.inspectdetail_classname)
    TextView inspectdetailClassname;
    @Bind(R.id.inspectdetail_time)
    TextView inspectdetailTime;
    @Bind(R.id.inspectdetail_result)
    TextView inspectdetailResult;
    @Bind(R.id.inspectdetail_diagnosis_title)
    TextView inspectdetailDiagnosisTitle;
    @Bind(R.id.inspectdetail_diagnosis)
    TextView inspectdetailDiagnosis;

    IContractManageInspectDetailPresenter presenter;
    String hosId,applyNo;

    @Override
    public void setRootView() {
        setContentView(R.layout.act_inspectdetail);
        ButterKnife.bind(this);
    }

    @Override
    public void initData() {
        super.initData();
        setTitle();
        hosId = getIntent().getExtras().getString("hosId");
        applyNo = getIntent().getExtras().getString("applyNo");
        presenter = new ContractManageInspectDetailPresenter(this,new ContractManageModel());
        ApiForGetList();
    }

    //请求详情
    private void ApiForGetList() {
        Map<String, String> params = new HashMap<>();
        params.put("sessionUuid", PreferenceHelper.readString(aty, AppConfig.USER_INFO, AppConfig.SESSION_ID));
        params.put("hospId", hosId);
        params.put("applyNo", applyNo);
        presenter.showContractManageInspectDetail(params);
    }


    public void setTitle() {
        titleTv.setText("检查报告单详情");
    }


    @OnClick(R.id.back)
    public void onClick() {
       finish();
    }

    @Override
    public void showContractManageInspectDetail(BaseEntity<ContractManageInspectDetailBean> contractManageInspectDetailBeanBaseEntity) {
        if(contractManageInspectDetailBeanBaseEntity.getStatus().equals("200"))
        {
            inspectdetailName.setText("姓名："+contractManageInspectDetailBeanBaseEntity.getDatas().get(0).getRows().get(0).getName());
            inspectdetailClassname.setText("名称："+contractManageInspectDetailBeanBaseEntity.getDatas().get(0).getRows().get(0).getDiag_name());
            inspectdetailTime.setText(contractManageInspectDetailBeanBaseEntity.getDatas().get(0).getRows().get(0).getApply_dtime());
            inspectdetailResult.setText(contractManageInspectDetailBeanBaseEntity.getDatas().get(0).getRows().get(0).getImage_pres());
            inspectdetailDiagnosis.setText(contractManageInspectDetailBeanBaseEntity.getDatas().get(0).getRows().get(0).getImage_result());
        }
    }
}
